-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefill with business name and type if they exist, change email domains #177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM, left one suggestion
@@ -63,6 +63,7 @@ export async function POST() { | |||
}, | |||
confirm: true, | |||
payment_method: 'pm_card_createDispute', | |||
receipt_email: '[email protected]', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see other fixes are bundled here, that's ok since they are very small (though I prefer separate changes) but would be good to mention in the PR description!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The picture in the description is a reference to this change!
@@ -269,7 +269,7 @@ export default function BusinessDetailsForm({email}: {email: string}) { | |||
const form = useForm<z.infer<typeof formSchema>>({ | |||
resolver: zodResolver(formSchema), | |||
defaultValues: { | |||
businessType: 'independent_salon', | |||
businessType: 'individual', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the initial state right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/auth.ts
Outdated
@@ -381,10 +382,23 @@ export const authOptions: AuthOptions = { | |||
console.log('Could not find an existing user for the email', email); | |||
return null; | |||
} | |||
let businessType = undefined; | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but would be good to do with a switch
statement, and to leverage a union type that has the possible values of businessType
, to ensure we are handling all cases. Like so:
switch (credentials?.businessType) {
case 'company':
case 'individual':
return credentials?.businessType;
default:
assertUnreachable(credentials?.businessType);
return 'individual'; // We default to individual, but rely on TS to catch missing cases
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
lib/auth.ts
Outdated
|
||
function getRandomInt(min: number, max: number) { | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
function assertUnreachable(option: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be typed with never
, so that the switch statement gives a compile time error when there is a new option
Disputes now have a customer
Business name and type are prefilled if they are specified:
Individual (taken straight to identity info page):
https://github.com/user-attachments/assets/b32e74af-db84-4c13-b764-a118f349055f
Other (have to pick)
https://github.com/user-attachments/assets/7f845753-d4b0-446d-a8bd-a88896b6e6da
Also tested with company but did not screen record